<?php 
namespace app\admin\Controller;
use app\admin\model\User;
class Home extends Admin
{
      public function index()
    {

         //curl初始化
        $curl = curl_init();

        //城市名
        $cityName = empty($_GET['city'])?'上海':$_GET['city'];
        $city = iconv('UTF-8', 'GBK', $cityName);
        $url = 'http://php.weather.sina.com.cn/xml.php?city='.$city.'&password=DJOYnieT8234jlsK&day=0';

        //设置URL
        curl_setopt($curl, CURLOPT_URL, $url);
        //将curl_exec()获取的信息以文件流的形式返回，而不是直接输出。 
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        //curl执行
        $data = curl_exec($curl);

        //关闭curl
        curl_close($curl);

        // 处理XML数据
        // var_dump($data);
        /*echo '<pre>';
            // print_r($data);
            echo htmlspecialchars($data);
        echo '</pre>';*/
        $obj = simplexml_load_string($data);//
        $this->assign('city',$obj->Weather->city);
        $this->assign('obj',$obj);
        $this->assign('cityName',$cityName);


       	$ft=db('article')
		->select();
		$count = count($ft);
		$this->assign('count',$count);

		$jrft=db('article')
		->whereTime('pubdate', 'today')
		->select();
		$count2 = count($jrft);
		$this->assign('count2',$count2);
		$user=db('user')
		->select();
		$count1 = count($user);
		$this->assign('count1',$count1);

		$user1=db('user')
		->whereTime('regtime', 'today')
		->select();
		$count3 = count($user1);
		$this->assign('count3',$count3);



         $no = db('notice')->where('status',1)->select();
         $this->assign('no',$no);
       

        return view('Index/admin-index');

    }
}